class InitialTables < ActiveRecord::Migration

  def self.up

    create_table :students do |t|
        # should uw_id be an integer instead of a string?
      t.string :uw_id, :null => false
      t.string :first_name, :null => false
      t.string :last_name, :null => false
      t.string :username, :null => false
      t.integer :expected_graduation, :null => false
      t.text :notes, :null => true

      t.timestamps
    end

    create_table :plans do |t|
      t.boolean :isValid, :default => false
      t.boolean :approved, :default => false
      t.string :errors, :null => true
      t.references :student, :null => false

      t.timestamps
    end

    create_table :planned_courses do |t|
      t.references :plan, :null => false
      t.references :course, :null => false
      t.integer  :term, :null => false

      t.timestamps
    end

    create_table :courses do |t|
      t.string :department, :null => false
      t.string :course_code, :null => false
      t.string :full_name, :null => false

      t.integer :cse_a
      t.integer :cse_b
      t.integer :cse_c
      t.integer :cse_d
      t.decimal :te_math
      t.decimal :te_sci
      t.decimal :te_engsci
      t.decimal :te_engdes

      t.boolean :offered_fall
      t.boolean :offered_winter
      t.boolean :offered_spring

      t.timestamps
    end

    create_table :offerings do |t|
      t.references :course, :null => false
      t.string :type, :null => false
      t.integer :section, :null => false
      t.integer :term, :null => false

      t.timestamps
    end

    create_table :timeslots do |t|
      t.references :offering, :null => false
      t.string :day, :null => false
      t.integer :start_time, :null => false
      t.integer :end_time, :null => false

      t.timestamps
    end

    create_table :schedules do |t|
      t.references :student, :null => false
      t.references :offering, :null => false

      t.timestamps
    end
  end

  def self.down
    drop_table :students
    drop_table :plans
    drop_table :planned_courses
    drop_table :courses
    drop_table :degree_requirements
    drop_table :offerings
    drop_table :timeslots
    drop_table :schedules
  end

end

